package com.example.demo.controller;

import com.example.demo.pojo.Member;
import com.example.demo.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
public class MemberController {
    @Autowired
    private MemberService memberService;

    @PostMapping(value = {"/h4/user/getMember"})
    public Map<String,Object> userLogin(@RequestBody Member member){
        Map map=new HashMap<String,Object>();
        Member member1=memberService.userLogin(member);
        if (member1!=null){ map.put("success",true);
            map.put("msg","成功");


        }else {
            map.put("success",false);
            map.put("msg","失败");
        }
        return map;
    }
    @PostMapping(value = {"/h5/user/addMember"})
    public Map<String,Object> userReg(@RequestBody Member member){
        Map map=new HashMap<String,Object>();
        int i=memberService.userReg(member);
        if (i==-1){
            map.put("success",false);
            map.put("msg","该用户已注册");
        }else {
            if (i>0){ map.put("success",true);
                map.put("msg","成功");


            }else {
                map.put("success",false);
                map.put("msg","失败");
            }
        }



        return map;
    }

}
